﻿using OPCPlatformCore.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OPCPlatformCore.Models.OPCUaModels
{
    public class OPCUaTagInfo
    {
        public string FriendlyName { get; private set; }
        public string Address { get; private set; }
        public string Value { get; private set; }
        public string DataType { get; private set; }
        public DateTime LastUpdateTime { get; private set; }
        public bool NeedRead { get; set; }
        public bool NeedWrite { get; set; }
        public OPCUaTagInfo(string friendlyName, string address)
        {
            if (string.IsNullOrEmpty(friendlyName))
            {
                throw new TagDefineException();
            }
            if (string.IsNullOrEmpty(address))
            {
                throw new TagDefineException(friendlyName);
            }
            FriendlyName = friendlyName;
            Address = address;
        }
        public void SetValue(string value)
        {
            Value = value;
            LastUpdateTime = DateTime.Now;
        }
        public void SetDataType(string dataType)
        {
            DataType = dataType;
        }
    }
}
